package cn.it.shop.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.it.shop.dao.SorderDao;
import cn.it.shop.model.Sorder;

@Repository("sorderDao")
@SuppressWarnings("unchecked")
public class SorderDaoImpl extends BaseDaoImpl<Sorder> implements
		SorderDao {

	@Override  //SELECT p.name,sum(s.number) FROM sorder s LEFT JOIN product p ON s.pid=p.id group by s.pid;
	public List<Object> querySaleTop10(int number) {
		String hql="SELECT p.name,sum(s.number) FROM Sorder s LEFT JOIN s.product p GROUP BY p.id";
		return getSession()		
		.createQuery(hql)
		.setFirstResult(0)
		.setMaxResults(number)
		.list();
	}
	
}
